# -*- coding:UTF-8 -*-
"""
@Project : pythonProject
@File    : decorator01.py
@IDE     : PyCharm
@Author  : WorldWind(1772830365@qq.com)
@Address : China - HeiLongjiang - Herbin
@Date    : 2025/7/15 下午8:49
"""
from time import time , sleep

from highLevelPython.July15_class_code.decorator_my_practice.util.login_check import LoginCheck


# 检验是否登录
def decorator(func):
    def new_func(*args, **kwargs):
        result = LoginCheck().check_login()
        print("这是decorator测试装饰器,如果输出这段话代表此装饰器启动")
        if result == 'success':
            return func(*args, **kwargs)
        else:
            return '异常'

    return new_func


# 此时方法运行了多长时间
def running_time(func):
    def new_func(*args, **kwargs):
        start = time()
        result = func(*args, **kwargs)
        print('这个是running_time装饰器,用来检验方法执行时间,如果输出此段文件,代表装饰器运行成功!')
        print(f'result:{result}')
        sleep(2)
        end = time()
        print(f'{func.__name__}方法:运行了:{round((end - start), 3)}s')
    return new_func
